﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ProDivingAdmin2salmon14
{
    public partial class StartUpForm : Form , IStartUpForm
    {
        public StartUpForm()
        {
            InitializeComponent();
            this.radioButtonFemale.Checked = true;
            this.comboBoxAge.SelectedIndex = 0;
            this.comboBoxHeight.SelectedIndex = 0;
            this.comboBoxJudges.SelectedIndex = 0;
        }


        public event DelegateSetIsFemale EventSetIsFemale = null;

        public event DelegateSetMinAge EventSetMinAge = null;

        public event DelegateSetDivingHeight EventSetDivingHeight = null;

        public event DelegateSetJudges EventSetJudges = null;

        public event DelegateSetDiversPath EventSetDiversPath = null;

        public event DelegateSetJudgesPath EventSetJudgesPath = null;

        public event DelegateGetIsFemaleData EventGetIsFemaleData = null;

        public event DelegateGetMinAge EventGetMinAge = null;

        public event DelegateGetDivingHeight EventGetDivingHeight = null;

        public event DelegateGetJudges EventGetJudges = null;

        public event DelegateGetDiversPath EventGetDiversPath = null;

        public event DelegateGetJudgesPath EventGetJudgesPath = null;

        private void buttonOpenDiver_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter = "Text Files (.txt)|*.txt";
            fileDialog.FilterIndex = 0;

            fileDialog.Multiselect = false;


            System.Windows.Forms.DialogResult result = fileDialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                this.textBoxDiverlistPath.Text = fileDialog.FileName;
            }
        }

        private void buttonOpenJudge_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter = "Text Files (.txt)|*.txt";
            fileDialog.FilterIndex = 0;

            fileDialog.Multiselect = false;

            System.Windows.Forms.DialogResult result = fileDialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                this.textBoxJudgePath.Text = fileDialog.FileName;
            }
        }

        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (EventSetIsFemale != null)
            {
                EventSetIsFemale(this.radioButtonFemale.Checked);
            }
            if (EventSetMinAge != null)
            {
                EventSetMinAge(Int32.Parse(this.comboBoxAge.SelectedItem.ToString().Trim('+')));
            }
            if (EventSetDivingHeight != null)
            {
                EventSetDivingHeight(Int32.Parse(this.comboBoxHeight.SelectedItem.ToString()));
            }
            if (EventSetJudges != null)
            {
                EventSetJudges(Int32.Parse(this.comboBoxJudges.SelectedItem.ToString()));
            }
            if (EventSetDiversPath != null)
            {
                EventSetDiversPath(this.textBoxDiverlistPath.Text);
            }
            if (EventSetJudgesPath != null)
            {
                EventSetJudgesPath(this.textBoxJudgePath.Text);
            }


            this.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
    }
}
